// miniprogram/pages/system/system.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    option1: [
      { text: '请修改', value: '请修改' },
      { text: 'TASK_STATUS', value: 'TASK_STATUS' },
      { text: 'RUNNING_STATUS', value: 'RUNNING_STATUS' },
      { text: 'DOC_TYPE', value: 'DOC_TYPE' },
      { text: 'BUG_LEVEL', value: 'BUG_LEVEL' },
      { text: 'BUG_TYPE', value: 'BUG_TYPE' },
      { text: 'SOLVETASK_STATUS', value: 'SOLVETASK_STATUS' }
    ],
    value1: '请修改',
    option2: [
      { text: '请修改', value: '请修改' },
      { text: '任务状态', value: '任务状态' },
      { text: '运行状态', value: '运行状态' },
      { text: '工作单据类型', value: '工作单据类型' },
      { text: '缺陷等级', value: '缺陷等级' },
      { text: '缺陷类型', value: '缺陷类型' },
      { text: '消缺任务状态', value: '消缺任务状态' }
    ],
    value2:'请修改',
    text:''
  },
  update(es){
    if (this.data.value1=='请修改'){
      wx.showToast({
        title: '请修改',
      })
      return
    } else if (this.data.value2 == '请修改') {
      wx.showToast({
        title: '请修改',
      })
      return
    }
    console.log('=1',this.data.value1)
    console.log('=1',this.data.value2)
    console.log('=1',this.data.text)
    console.log('=1',this.data.checked)
    if (this.data.checked==true){
      this.data.checked=1
    } else if (this.data.checked == false){
      this.data.checked = 2
    }

    wx.request({
      url: getApp().appData.site +'/accp/psSystemconfig/update',
      data: {
        id: this.data.dataInfo,
        configCode: this.data.value1,
        configName: this.data.value2,
        descQ: this.data.text,
        isStart: this.data.checked
      },
      success: (res) => {
        console.log('成功', res)
        this.setData({
          show: false
        });
        wx.request({
          url: getApp().appData.site +'/accp/psSystemconfig/System',
          success: (res) => {
            console.log(res)
            console.log(res.data)
            this.setData({
              aa: res.data
            })
            console.log('aa', this.data.aa)
          }
        })
      },
      fail: (ex) => {
        console.log('失败');
      }
    })

  },
  rname(e){
      this.setData({
        text: e.detail.value
      })
    console.log(this.data.text)
  },
  onChange01({ detail }) {
    console.log("detail", detail)
    wx.showModal({
      title: '提示',
      content: '是否启用？',
      success: res => {
        if (res.confirm) {
          this.setData({
            checked: detail
          });
        }
        console.log(3, this.data.checked)
      }
    });
  },
  xo(ex1){
    this.setData({
      value1: ex1.detail
    })
    console.log('01', this.data.value1);
  },
  xo2(ex2){
    this.setData({
      value2: ex2.detail
    })
    console.log('02', this.data.value2);
  },
  onClose2() {
    this.setData({ show: false });
  },
  onClose() {
    this.setData({ show: false });
    wx.request({
      url: getApp().appData.site +'/accp/psSystemconfig/System',
      success: (res) => {
        console.log(res)
        console.log(res.data)
        this.setData({
          aa: res.data
        })
        console.log('aa', this.data.aa)
      }
    })
  },
  ss(ee2){

    console.log(ee2)
    const dataInfo = ee2.currentTarget.dataset.info;
    console.log('22', dataInfo)
    this.setData({
      show: true,
      dataInfo: ee2.currentTarget.dataset.info
    });

    wx.request({
      url: getApp().appData.site+'/accp/psSystemconfig/selectid',
      data: {
        id: dataInfo
      },
      success: (res) => {
        console.log('成功', res)
        this.setData({
          aa: res.data,
          value1: res.data.configCode,
          value2: res.data.configName,
          text:res.data.descQ,
          checked:res.data.isStartStr2
          
        })
      },
      fail: (ex) => {
        console.log('失败');
      }
    })
  },
  xx(ee) {
    console.log('00', ee)
    const dataInfo = ee.currentTarget.dataset.info;
    console.log('11', dataInfo)
    wx.showModal({
      title: '',
      content: '是否确认删除',
      success(res) {
        if (res.confirm) {
          wx.request({
            url: getApp().appData.site+'/accp/psSystemconfig/del',
            data: {
              id: dataInfo
            },
            success: (res) => {
              console.log('删除成功')
              wx.redirectTo({
                url: '../system/system',
              })
            }
          })

        } else if (res.cancel) {
          console.log('取消')
         
        }
      }
    })
  },
  xinzeng() {
    console.log(11)
    wx.navigateTo({
      url: '/pages/systemInsert/system',
    })
  },
  onLoad: function(options) {
    wx.request({
      url: getApp().appData.site+'/accp/psSystemconfig/System',
      success: (res) => {
        console.log(res)
        console.log(res.data)
        this.setData({
          aa: res.data
        })
        console.log('aa', this.data.aa)
      }
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})